<template>
  <Menu v-if="isShowMenu"/>
  <router-view v-slot="{ Component }">
    <keep-alive include="Search">
      <component :is="Component" />
    </keep-alive>
  </router-view>
<!--  <button @click="updateWidget()">更换</button>-->
</template>

<script setup>
  import {useRouter} from "vue-router"
  import {ref,onBeforeMount} from "vue"

  import Menu from "./components/Menu.vue"
  import {useUserStore} from "./config/pinia/user.js"
  import {useWidgetStore} from "./config/pinia/widget.js"

  //是否显示导航组件
  const isShowMenu = ref(true)
  //路由器对象
  const router = useRouter()

  //路由守卫
  router.beforeEach((to, from, next)=>{
    isShowMenu.value = !to.meta.isScreenFul
    next()
  })

  //用户状态
  const userStore = useUserStore()

  //小部件控制
  const widgetStore = useWidgetStore()

  onBeforeMount(()=>{
    //初始化小部件
    widgetStore.setWidget({path: "haru_1",model: "haru01"})
    //初始化用户数据
    userStore.init()
  })


</script>

<style>
*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;

}
:root{
  --el-text-color-primary: #000000 !important; /*字体颜色*/
  --el-bg-color: #ffffff !important; /*背景颜色*/
  --el-color-primary: #09c !important; /*激活状态字体颜色*/
}
</style>
